package com.easondongh.system.controller;

import com.easondongh.system.domain.SysLog;
import com.easondongh.common.enums.ResponseEnum;
import com.easondongh.common.response.ResponseObj;
import com.easondongh.system.service.SysLogService;
import com.easondongh.common.vo.BasePageQueryVo;
import com.easondongh.system.vo.LogQueryVo;
import com.easondongh.common.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统日志相关
 * @author EasonDongH
 * @date 2020/4/30 11:09
 */
@RestController
@RequestMapping("/log")
public class LogController {

    @Autowired
    private SysLogService logService;

    /**
     * 根据条件分页查询日志
     * @param queryCondition
     * @return
     */
    @PostMapping("/getByPage")
    public ResponseObj<PageResult<SysLog>> getByPage(@RequestBody BasePageQueryVo<LogQueryVo> queryCondition) {
        PageResult<SysLog> result = this.logService.getByPage(queryCondition);
        return new ResponseObj<>(ResponseEnum.QUERY_SUCCESS, result);
    }

    /**
     * 批量删除日志
     * @param ids
     * @return
     */
    @DeleteMapping("/deleteByIds")
    public ResponseObj deleteByIds(@RequestBody List<Integer> ids) {
        if(ids != null && ids.size() > 0) {
            this.logService.deleteByIds(ids);
        }
        return new ResponseObj(ResponseEnum.DELETE_SUCCESS);
    }
}
